# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Firegem <mrfiregem [at] protonmail [dot] ch>

pkgname=taplo-cli
pkgver=0.8.1
pkgrel=1
pkgdesc='TOML toolkit written in Rust'
arch=('loong64' 'x86_64')
url=https://taplo.tamasfe.dev/cli/introduction.html
license=('MIT')
depends=('gcc-libs')
makedepends=('cargo')
provides=("${pkgname%-cli}")
options=('!lto')
source=(
  "$pkgname-$pkgver.tar.gz::https://static.crates.io/crates/$pkgname/$pkgname-$pkgver.crate"
  "$pkgname-$pkgver-LICENSE.md::https://raw.githubusercontent.com/tamasfe/taplo/release-$pkgname-$pkgver/LICENSE.md"
)
b2sums=('f5b8a1b1f10b42ddb98c7ea400a062715e3ab9c2023adece88052126847ab992db522584d8c37fb6fc348e952839a638e8eae8b3e36667d6357ef9c21e2ae364'
        '2b1282c2e1b54a67fd56894ae96a1447d954b52fecdf0730d8c3fe7a95ccf79245e738588a9bda7262eb0ef2507cdeded228346358894d4bbfc540ec90069964')

prepare() {
  cd $pkgname-$pkgver
#  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd $pkgname-$pkgver
  find -name Cargo.lock -exec rm -f {} \;
  mkdir -p .cargo
  cat > .cargo/config.toml <<EOF
[source.crates-io]
registry = "https://gitee.com/yetist/crates.io-index"
EOF
  cargo build --release --offline --all-features
}

package() {
  cd $pkgname-$pkgver
  install -Dt "$pkgdir"/usr/bin target/release/${pkgname%-cli}
  install -Dm644  ../$pkgname-$pkgver-LICENSE.md \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.md
}
